﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace SIGCBI.WebMVC4.Controllers
{
    public class ReporteController : Controller
    {
        //
        // GET: /Reporte/

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult GastosTotales()
        {
            string sServidor = "http://localhost/ReportServer";
            string sCarpeta = "SICBI";
            string sReporte = "GastosTotales";
            //Los parámetros con sus respectivos valores
            //string sParametroValor = "&IdPecosa=" + id.Trim();
            //Comandos a pasar al Visor de Reporting Services
            //Esos comandos los consigue en: hhttp://technet.microsoft.com/es-ve/library/ms152835.aspx
            string sComandosRS = "&rs:Command=Render&rs:Format=HTML4.0&rc:Parameters=false";
            //StringBuilder para crear un iFrame
            StringBuilder sb = new StringBuilder();
            sb.Append("<iframe id='ifReporte' width='100%' style='height: 480px' frameborder='0'");
            //sb.AppendFormat("src='{0}?/{1}/{2}{3}{4}'", sServidor, sCarpeta, sReporte, sParametroValor, sComandosRS);
            sb.AppendFormat("src='{0}?/{1}/{2}{3}'", sServidor, sCarpeta, sReporte, sComandosRS);
            sb.Append("></iframe>");
            //sb.AppendFormat("src='{0}?/{1}/{2}{3}{4}'", sServidor, sCarpeta, sReporte, sParametroValor, sComandosRS);
            return this.Json(sb.ToString(), JsonRequestBehavior.AllowGet);
        }

        public JsonResult GastosDetallados()
        {
            string sServidor = "http://localhost/ReportServer";
            string sCarpeta = "SICBI";
            string sReporte = "GastosDetallados";
            string sComandosRS = "&rs:Command=Render&rs:Format=HTML4.0&rc:Parameters=false";
            StringBuilder sb = new StringBuilder();
            sb.Append("<iframe id='ifReporte' width='100%' style='height: 500px' frameborder='0'");
            sb.AppendFormat("src='{0}?/{1}/{2}{3}'", sServidor, sCarpeta, sReporte, sComandosRS);
            sb.Append("></iframe>");

            return this.Json(sb.ToString(), JsonRequestBehavior.AllowGet);
        }

        public JsonResult GastosPorCentro(int id)
        {
            string sServidor = "http://localhost/ReportServer";
            string sCarpeta = "SICBI";
            string sReporte = "GastosDetallados";
            string sComandosRS = "&rs:Command=Render&rs:Format=HTML4.0&rc:Parameters=false";
            StringBuilder sb = new StringBuilder();
            sb.Append("<iframe id='ifReporte' width='100%' style='height: 500px' frameborder='0'");
            sb.AppendFormat("src='{0}?/{1}/{2}{3}'", sServidor, sCarpeta, sReporte, sComandosRS);
            sb.Append("></iframe>");

            return this.Json(sb.ToString(), JsonRequestBehavior.AllowGet);
        }


    }
}
